<!DOCTYPE html>
<html class="loginHtml" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<title>房产中介后台登录</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="icon" th:href="@{/favicon.ico}">
	<link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
	<link rel="stylesheet" th:href="@{/css/public.css}" media="all" />
	<script>
		<!-- 解决登录页面嵌套问题 -->
		if (window != top){
			top.location.href = location.href;
		}
	</script>
	<style>
		.logo-title {text-align:center;letter-spacing:2px;padding:14px 0;}
		.logo-title h1 {color:#1E9FFF;font-size:25px;font-weight:bold;}
	</style>
</head>
<body class="loginBody">
<form class="layui-form">
	<div class="layui-form-item logo-title">
		<h1>房产中介后台登录</h1>
	</div>
	<div class="layui-form-item input-item">
		<label for="userName">用户名</label>
		<input type="text" placeholder="请输入用户名" name="username" autocomplete="off" id="username" class="layui-input" lay-verify="required">
	</div>
	<div class="layui-form-item input-item">
		<label for="password">密码</label>
		<input type="password" placeholder="请输入密码" name="password" autocomplete="off" id="password" class="layui-input" lay-verify="required">
	</div>
	<div class="layui-form-item">
		<input type="checkbox" name="rememberMe" value="true" lay-skin="primary" title="记住密码">
	</div>
	<div class="layui-form-item">
		<button class="layui-btn layui-btn-normal layui-btn-fluid" id="login" lay-filter="login" lay-submit>登录</button>
	</div>
</form>
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/js/cache.js}"></script>
<script type="text/javascript">
	layui.use(['form','layer','jquery'],function(){
		var form = layui.form,
				layer = parent.layer === undefined ? layui.layer : top.layer
		$ = layui.jquery;

		//登录按钮
		form.on("submit(login)",function(data){
			$(this).text("登录中...").attr("disabled","disabled").addClass("layui-disabled");
			$.post("/doLogin", data.field, function (res) {
				layer.msg(res.msg);
				if(res.status===200){
					setTimeout(function(){
						window.location.href = "/admin";
					},1000);
				}else{
					$("#login").text("登录").removeAttr("disabled").removeClass("layui-disabled");
				}
			})
			return false;
		})

		//表单输入效果
		$(".loginBody .input-item").click(function(e){
			e.stopPropagation();
			$(this).addClass("layui-input-focus").find(".layui-input").focus();
		})
		$(".loginBody .layui-form-item .layui-input").focus(function(){
			$(this).parent().addClass("layui-input-focus");
		})
		$(".loginBody .layui-form-item .layui-input").blur(function(){
			$(this).parent().removeClass("layui-input-focus");
			if($(this).val() != ''){
				$(this).parent().addClass("layui-input-active");
			}else{
				$(this).parent().removeClass("layui-input-active");
			}
		})
	})

</script>
</body>
</html>